<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="app">
        <button @click="changeData">点击修改数据</button>
        <h3 v-for="value,key in obj">{{key}}: {{value}}</h3>
    </div>
    <script>
        //数据是简单数据时 直接修改会有响应式
        const vm = new Vue({
            data(){
              return{
                obj:{
                    name:"小康",
                    age:18,
                    hobby:["打篮球","写代码"]
                }
              }
            },
            methods:{
                changeData(){
                    // 对象中的属性可以直接修改赋值
                    // this.obj.name="阿幸"
                    //新增属性
                    // Vue.set(this.obj,"sex","nan")
                    //删除属性
                    Vue.delete(this.obj,"hobby")

                }
            }
        }).$mount("#app")
    </script>
</body>

</html>